/*
 *  Copyright (C) 2010 Glauco
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.swing.commons;

import javax.swing.JButton;
import org.balisunrise.common.abstracts.AbstractVisualizable;
import org.balisunrise.common.defaults.DefaultAction;

/**
 *
 * @author Glauco
 */
public class VisualAction extends DefaultAction
        implements org.balisunrise.common.VisualAction<JButton>{

    public static final String PROP_VISUAL_REPRESENTATION = 
            "visualRepresentation";

    /**
     * Representação visual da Ação. Neste caso será sempre um botão.
     */
    private JButton visualRepresentation;

    /**
     * Atribui a representação visual desta VisualAction.
     * @param button @{@link javax.swing.JButton}
     */
    public void setVisualRepresentation(JButton button) {
        JButton old = this.visualRepresentation;
        this.visualRepresentation = button;
        changeSupport.firePropertyChange(PROP_VISUAL_REPRESENTATION, old,
                visualRepresentation);
    }

    /**
     * Representação visual.
     * @return
     */
    @Override
    public JButton getVisualRepresentation() {
        return visualRepresentation;
    }

    /**
     * Atribui um valor a uma propriedade da representação visual.
     * @param property propriedade da representação visual.
     * @param value valor a ser atribuido.
     * @return verdadeiro se foi atribuido, falso caso ocorreu alguma exception.
     */
    @Override
    public boolean setProperty(String property, Object value) {
        return AbstractVisualizable
                .setProperty(visualRepresentation, property, value);
    }
}
